import { EventType } from "./../Base/EventType";
import GameInstance from "./../GameInstance";

const { ccclass, property } = cc._decorator;
@ccclass
export default class NewClass extends cc.Component {

    @property(cc.Node)
    public graphicsLayer: cc.Node = null;

    @property(cc.Node)
    public labelLayer: cc.Node = null;


    onLoad() {
        GameInstance.getInstance().setRenderLayer(this.node);


        this.node.on(EventType.DrawNode.toString(), this.drawNode.bind(this));
    }

    drawNode() {
        console.log("绘制节点");
        let nodeList = GameInstance.getInstance().nodeList;
        let graphics = this.graphicsLayer.getComponent(cc.Graphics);
        for (let i = 0; i < nodeList.length; i++) {
            let node = nodeList[i];
            node.render(graphics, this.labelLayer);
        }


    }


    start() {

    }
    update(dt) { }
}
